home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / PXFIELD.CPP < prev    next >
Text File  |  1992-02-06  |  23KB  |  877 lines

  1. // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
  2.  
  3. // PXFIELD.CPP //
  4.  
  5. // Contents ----------------------------------------------------------------
  6. //
  7. //    This module contains all members to access field related classes.
  8. //
  9. // End ---------------------------------------------------------------------
  10.  
  11. // External Reference Name for this Header ---------------------------------
  12.  
  13. #ifndef PXFIELD_CPP
  14.     #define PXFIELD_CPP
  15.  
  16. // End ---------------------------------------------------------------------
  17.  
  18. // Interface Dependencies --------------------------------------------------
  19.  
  20. #ifndef PXFIELD_HPP
  21.     #include "pxfield.hpp"
  22. #endif // PXFIELD_HPP //
  23.  
  24. // End ---------------------------------------------------------------------
  25.  
  26. // member build of PXFieldTypeBase //
  27.  
  28. PTStreamable PXFieldTypeBase::build()
  29. {
  30.     return new PXFieldTypeBase(streamableInit);
  31. }
  32.  
  33. TStreamableClass RegPXFieldTypeBase("PXFieldTypeBase",PXFieldTypeBase::build,
  34.     __DELTA(PXFieldTypeBase));
  35.  
  36. // Description -------------------------------------------------------------
  37. //
  38. //    When the streamable constructor is called, TStreamable dispatches
  39. //    the build member to construct the object.  To do this, it must
  40. //    know where to find this member functions for the specific class.
  41. //    This is the reason for the stream registration.
  42. //
  43. // End ---------------------------------------------------------------------
  44.  
  45. // member read of PXFieldTypeBase //
  46.  
  47. inline Pvoid PXFieldTypeBase::read(Ripstream)
  48. {
  49.     return this;
  50. }
  51.  
  52. // Description -------------------------------------------------------------
  53. //
  54. //    Nothing taken from the stream.
  55. //
  56. // End ---------------------------------------------------------------------
  57.  
  58. // member write of PXFieldTypeBase //
  59.  
  60. inline void PXFieldTypeBase::write(Ropstream)
  61. {
  62.  
  63. }
  64.  
  65. // Description -------------------------------------------------------------
  66. //
  67. //    Nothing put on the stream.
  68. //
  69. // End ---------------------------------------------------------------------
  70.  
  71. // constructor PXFieldTypeChar //
  72.  
  73. inline PXFieldTypeChar::PXFieldTypeChar(PPXField my_field,int sz):
  74.     PXFieldTypeBase(my_field)
  75. {
  76.     size = sz + 1;
  77.     char_size = sz;
  78.  
  79.     // Create buffer space
  80.  
  81.     data = new char[size];
  82.  
  83.     char_dat = data;        /* No conversion necessary
  84.                        for this type */
  85. }
  86.  
  87. // Summary -----------------------------------------------------------------
  88. //
  89. //    Initializes a field of type char.
  90. //
  91. // Parameters
  92. //
  93. //     my_field.  Points to the field base object.
  94. //
  95. //    sz.  Size of the field in bytes.
  96. //
  97. // Description
  98. //
  99. //    Set size of character data to size and char_size.  Create a buffer
  100. //    of size characters and set the char_dat pointer to this pointer.
  101. //    Since there is no conversion necessary, the char_dat pointer is the
  102. //    same as the data pointer.
  103. //
  104. // End ---------------------------------------------------------------------
  105.  
  106. // destructor PXFieldTypeChar //
  107.  
  108. inline PXFieldTypeChar::~PXFieldTypeChar(void)
  109. {
  110.     delete data;
  111.     data = NULL;
  112. }
  113.  
  114. // Summary -----------------------------------------------------------------
  115. //
  116. //    delete data buffer.
  117. //
  118. // End ---------------------------------------------------------------------
  119.  
  120. // member build of PXFieldTypeChar //
  121.  
  122. PTStreamable PXFieldTypeChar::build()
  123. {
  124.     return new PXFieldTypeChar(streamableInit);
  125. }
  126.  
  127. TStreamableClass RegPXFieldTypeChar("PXFieldTypeChar",PXFieldTypeChar::build,
  128.     __DELTA(PXFieldTypeChar));
  129.  
  130. // Description -------------------------------------------------------------
  131. //
  132. //    When the streamable constructor is called, TStreamable dispatches
  133. //    the build member to construct the object.  To do this, it must
  134. //    know where to find this member functions for the specific class.
  135. //    This is the reason for the stream registration.
  136. //
  137. // End ---------------------------------------------------------------------
  138.  
  139. // member read of PXFieldTypeChar //
  140.  
  141. inline Pvoid PXFieldTypeChar::read(Ripstream)
  142. {
  143.     return this;
  144. }
  145.  
  146. // Summary -----------------------------------------------------------------
  147. //
  148. //     Nothing taken from the stream.
  149. //
  150. // End ---------------------------------------------------------------------
  151.  
  152. // member write of PXFieldTypeChar //
  153.  
  154. inline void PXFieldTypeChar::write(Ropstream)
  155. {
  156.  
  157. }
  158.  
  159. // Summary -----------------------------------------------------------------
  160. //
  161. //    Nothing put on the stream.
  162. //
  163. // End ---------------------------------------------------------------------
  164.  
  165. // member Get of PXFieldTypeChar //
  166.  
  167. inline int PXFieldTypeChar::Get(void)
  168. {
  169.     if((EngDataPtr->Errors.pxerr = PXGetAlpha(*recHandle,fld,size,
  170.         data)) != PXSUCCESS)
  171.         PXError(ENG_ERROR);
  172.     return EngDataPtr->Errors.pxerr;
  173. }
  174.  
  175. // Summary -----------------------------------------------------------------
  176. //
  177. //    Get the character data from the record buffer.
  178. //
  179. // Return Value
  180. //
  181. //    pxerr.  Return PDOX error code.
  182. //
  183. // End ---------------------------------------------------------------------
  184.  
  185. // member Put of PXFieldTypeChar //
  186.  
  187. inline int PXFieldTypeChar::Put(void)
  188. {
  189.     if((EngDataPtr->Errors.pxerr = PXPutAlpha(*recHandle,fld,data))
  190.         != PXSUCCESS)
  191.         PXError(ENG_ERROR);
  192.     return EngDataPtr->Errors.pxerr;
  193. }
  194.  
  195. // Summary -----------------------------------------------------------------
  196. //
  197. //    Put the character data into the record transfer buffer.
  198. //
  199. // Return Value
  200. //
  201. //    pxerr.  Returns PDOX error status.
  202. //
  203. // End ---------------------------------------------------------------------
  204.  
  205. // constructor PXFieldTypeDouble //
  206.  
  207. inline PXFieldTypeDouble::PXFieldTypeDouble(PPXField my_field):
  208.     PXFieldTypeBase(my_field)
  209. {
  210.     char_size = DOUBLE_SIZE;
  211.  
  212.     // Create buffer space
  213.  
  214.     data = new double;
  215.     char_dat = new char[char_size + 1];
  216. }
  217.  
  218. // Summary -----------------------------------------------------------------
  219. //
  220. //    Initialize double type fields.
  221. //
  222. // Parameters
  223. //
  224. //    my_field.  Pass the field object to copy the handles.
  225. //
  226. // Functional Description
  227. //
  228. //    Set char_size to DOUBLE_SIZE for holding the text results of the
  229. //    double value.  Create the buffer space for the double number and
  230. //    the character version of the number.
  231. //
  232. // End ---------------------------------------------------------------------
  233.  
  234. // destructor PXFieldTypeDouble //
  235.  
  236. inline PXFieldTypeDouble::~PXFieldTypeDouble(void)
  237. {
  238.     delete data;
  239.     data = NULL;
  240.     delete char_dat;
  241.     char_dat = NULL;
  242. }
  243.  
  244. // Summary -----------------------------------------------------------------
  245. //
  246. //    Delete the data and character buffers.
  247. //
  248. // End ---------------------------------------------------------------------
  249.  
  250. // member build of PXFieldTypeDouble //
  251.  
  252. PTStreamable PXFieldTypeDouble::build()
  253. {
  254.     return new PXFieldTypeDouble(streamableInit);
  255. }
  256.  
  257. TStreamableClass RegPXFieldTypeDouble("PXFieldTypeDouble",PXFieldTypeDouble::build,
  258.     __DELTA(PXFieldTypeDouble));
  259.  
  260. // Description -------------------------------------------------------------
  261. //
  262. //    When the streamable constructor is called, TStreamable dispatches
  263. //    the build member to construct the object.  To do this, it must
  264. //    know where to find this member functions for the specific class.
  265. //    This is the reason for the stream registration.
  266. //
  267. // End ---------------------------------------------------------------------
  268.  
  269. // member read of PXFieldTypeDouble //
  270.  
  271. inline Pvoid PXFieldTypeDouble::read(Ripstream)
  272. {
  273.     return this;
  274. }
  275.  
  276. // member write of PXFieldTypeDouble //
  277.  
  278. inline void PXFieldTypeDouble::write(Ropstream)
  279. {
  280.  
  281. }
  282.  
  283. // member Get of PXFieldTypeDouble //
  284.  
  285. inline int PXFieldTypeDouble::Get(void)
  286. {
  287.     if((EngDataPtr->Errors.pxerr = PXGetDoub(*recHandle,fld,data))
  288.         != PXSUCCESS)
  289.         PXError(ENG_ERROR);
  290.     sprintf(char_dat,"%g",*data);
  291.     return EngDataPtr->Errors.pxerr;
  292. }
  293.  
  294. // Summary -----------------------------------------------------------------
  295. //
  296. //     Get the double data and convert it to character data.
  297. //
  298. // Return Value
  299. //
  300. //    pxerr.  Return PDOX error code.
  301. //
  302. // End ---------------------------------------------------------------------
  303.  
  304. // member Put of PXFieldTypeDouble //
  305.  
  306. inline int PXFieldTypeDouble::Put(void)
  307. {
  308.     if((EngDataPtr->Errors.pxerr = PXPutDoub(*recHandle,fld,*data))
  309.         != PXSUCCESS)
  310.         PXError(ENG_ERROR);
  311.     return EngDataPtr->Errors.pxerr;
  312. }
  313.  
  314. // Summary -----------------------------------------------------------------
  315. //
  316. //    Put the data from the data buffer into the record buffer.
  317. //
  318. // End ---------------------------------------------------------------------
  319.  
  320. // constructor PXFieldTypeLong //
  321.  
  322. inline PXFieldTypeLong::PXFieldTypeLong(PPXField my_field):
  323.     PXFieldTypeBase(my_field)
  324. {
  325.     char_size = LONGSIZE;
  326.  
  327.     // Create buffer space
  328.  
  329.     data = new long;
  330.     char_dat = new char[char_size + 1];
  331. }
  332.  
  333. // Summary -----------------------------------------------------------------
  334. //
  335. //    Initialize double type fields.
  336. //
  337. // Parameters
  338. //
  339. //    my_field.  Pass the field object to copy the handles.
  340. //
  341. // Functional Description
  342. //
  343. //    Set char_size to LONGSIZE for holding the text results of the
  344. //    long value.  Create the buffer space for the long number and
  345. //    the character version of the number.
  346. //
  347. // End ---------------------------------------------------------------------
  348.  
  349. // destructor PXFieldTypeLong //
  350.  
  351. inline PXFieldTypeLong::~PXFieldTypeLong(void)
  352. {
  353.     delete data;
  354.     data = NULL;
  355.     delete char_dat;
  356.     char_dat = NULL;
  357. }
  358.  
  359. // Summary -----------------------------------------------------------------
  360. //
  361. //    Delete the data and character buffers.
  362. //
  363. // End ---------------------------------------------------------------------
  364.  
  365. // member build of PXFieldTypeLong //
  366.  
  367. PTStreamable PXFieldTypeLong::build()
  368. {
  369.     return new PXFieldTypeLong(streamableInit);
  370. }
  371.  
  372. TStreamableClass RegPXFieldTypeLong("PXFieldTypeLong",PXFieldTypeLong::build,
  373.     __DELTA(PXFieldTypeLong));
  374.  
  375. // Description -------------------------------------------------------------
  376. //
  377. //    When the streamable constructor is called, TStreamable dispatches
  378. //    the build member to construct the object.  To do this, it must
  379. //    know where to find this member functions for the specific class.
  380. //    This is the reason for the stream registration.
  381. //
  382. // End ---------------------------------------------------------------------
  383.  
  384. // member read of PXFieldTypeLong //
  385.  
  386. inline Pvoid PXFieldTypeLong::read(Ripstream)
  387. {
  388.     return this;
  389. }
  390.  
  391. // member write of PXFieldTypeLong //
  392.  
  393. inline void PXFieldTypeLong::write(Ropstream)
  394. {
  395.  
  396. }
  397.  
  398. // member Get of PXFieldTypeLong //
  399.  
  400. inline int PXFieldTypeLong::Get(void)
  401. {
  402.     if((EngDataPtr->Errors.pxerr = PXGetLong(*recHandle,fld,data))
  403.         != PXSUCCESS)
  404.         PXError(ENG_ERROR);
  405.     sprintf(char_dat,"%g",*data);
  406.     return EngDataPtr->Errors.pxerr;
  407. }
  408.  
  409. // Summary -----------------------------------------------------------------
  410. //
  411. //     Get the long data and convert it to character data.
  412. //
  413. // Return Value
  414. //
  415. //    pxerr.  Return PDOX error code.
  416. //
  417. // End ---------------------------------------------------------------------
  418.  
  419. // member Put of PXFieldTypeLong //
  420.  
  421. inline int PXFieldTypeLong::Put(void)
  422. {
  423.     if((EngDataPtr->Errors.pxerr = PXPutLong(*recHandle,fld,*data))
  424.         != PXSUCCESS)
  425.         PXError(ENG_ERROR);
  426.     return EngDataPtr->Errors.pxerr;
  427. }
  428.  
  429. // Summary -----------------------------------------------------------------
  430. //
  431. //    Put the data from the data buffer into the record buffer.
  432. //
  433. // End ---------------------------------------------------------------------
  434.  
  435. // constructor PXFieldTypeShort //
  436.  
  437. inline PXFieldTypeShort::PXFieldTypeShort(PPXField my_field):
  438.     PXFieldTypeBase(my_field)
  439. {
  440.     // Copy record and field handles
  441.  
  442.     char_size = SHORT_SIZE;
  443.  
  444.     // Create buffer space
  445.  
  446.     data = new short;
  447.     char_dat = new char[char_size + 1];
  448. }
  449.  
  450. // Summary -----------------------------------------------------------------
  451. //
  452. //    Initialize double type fields.
  453. //
  454. // Parameters
  455. //
  456. //    my_field.  Pass the field object to copy the handles.
  457. //
  458. // Functional Description
  459. //
  460. //    Set char_size to SHORT_SIZE for holding the text results of the
  461. //    short value.  Create the buffer space for the short number and
  462. //    the character version of the number.
  463. //
  464. // End ---------------------------------------------------------------------
  465.  
  466. // destructor PXFieldTypeShort //
  467.  
  468. inline PXFieldTypeShort::~PXFieldTypeShort(void)
  469. {
  470.     delete data;
  471.     data = NULL;
  472.     delete char_dat;
  473.     char_dat = NULL;
  474. }
  475.  
  476. // Summary -----------------------------------------------------------------
  477. //
  478. //    Delete the data and character buffers.
  479. //
  480. // End ---------------------------------------------------------------------
  481.  
  482. // member build of PXFieldTypeShort //
  483.  
  484. PTStreamable PXFieldTypeShort::build()
  485. {
  486.     return new PXFieldTypeShort(streamableInit);
  487. }
  488.  
  489. TStreamableClass RegPXFieldTypeShort("PXFieldTypeShort",PXFieldTypeShort::build,
  490.     __DELTA(PXFieldTypeShort));
  491.  
  492. // Description -------------------------------------------------------------
  493. //
  494. //    When the streamable constructor is called, TStreamable dispatches
  495. //    the build member to construct the object.  To do this, it must
  496. //    know where to find this member functions for the specific class.
  497. //    This is the reason for the stream registration.
  498. //
  499. // End ---------------------------------------------------------------------
  500.  
  501. // member read of PXFieldTypeShort //
  502.  
  503. inline Pvoid PXFieldTypeShort::read(Ripstream)
  504. {
  505.     return this;
  506. }
  507.  
  508. // member write of PXFieldTypeShort //
  509.  
  510. inline void PXFieldTypeShort::write(Ropstream)
  511. {
  512.  
  513. }
  514.  
  515. // member Get of PXFieldTypeShort //
  516.  
  517. inline int PXFieldTypeShort::Get(void)
  518. {
  519.     if((EngDataPtr->Errors.pxerr = PXGetShort(*recHandle,fld,data))
  520.         != PXSUCCESS)
  521.         PXError(ENG_ERROR);
  522.     sprintf(char_dat,"%d",*data);
  523.     return EngDataPtr->Errors.pxerr;
  524. }
  525.  
  526. // Summary -----------------------------------------------------------------
  527. //
  528. //     Get the short data and convert it to character data.
  529. //
  530. // Return Value
  531. //
  532. //    pxerr.  Return PDOX error code.
  533. //
  534. // End ---------------------------------------------------------------------
  535.  
  536. // member Put of PXFieldTypeShort //
  537.  
  538. inline int PXFieldTypeShort::Put(void)
  539. {
  540.     if((PXPutShort(*recHandle,fld,*data)) != PXSUCCESS)
  541.         PXError(ENG_ERROR);
  542.     return EngDataPtr->Errors.pxerr;
  543. }
  544.  
  545. // Summary -----------------------------------------------------------------
  546. //
  547. //    Put the data from the data buffer into the record buffer.
  548. //
  549. // End ---------------------------------------------------------------------
  550.  
  551. // constructor PXFieldTypeDate //
  552.  
  553. inline PXFieldTypeDate::PXFieldTypeDate(PPXField my_field):
  554.     PXFieldTypeBase(my_field)
  555. {
  556.     // Copy record and field handles
  557.  
  558.     char_size = DATE_SIZE;
  559.  
  560.     // Create buffer space
  561.  
  562.     data = new DATES;
  563.     char_dat = new char[char_size + 1];
  564. }
  565.  
  566. // Summary -----------------------------------------------------------------
  567. //
  568. //    Initialize DATES type fields.
  569. //
  570. // Parameters
  571. //
  572. //    my_field.  Pass the field object to copy the handles.
  573. //
  574. // Functional Description
  575. //
  576. //    Set char_size to DATE_SIZE for holding the text results of the
  577. //    DATES value.  Create the buffer space for the DATES structure and
  578. //    the character version of the structure.
  579. //
  580. // End ---------------------------------------------------------------------
  581.  
  582. // destructor PXFieldTypeDate //
  583.  
  584. inline PXFieldTypeDate::~PXFieldTypeDate(void)
  585. {
  586.     delete data;
  587.     data = NULL;
  588.     delete char_dat;
  589.     char_dat = NULL;
  590. }
  591.  
  592. // Summary -----------------------------------------------------------------
  593. //
  594. //    Delete the data and character buffers.
  595. //
  596. // End ---------------------------------------------------------------------
  597.  
  598. // member build of PXFieldTypeDate //
  599.  
  600. PTStreamable PXFieldTypeDate::build()
  601. {
  602.     return new PXFieldTypeDate(streamableInit);
  603. }
  604.  
  605. TStreamableClass RegPXFieldTypeDate("PXFieldTypeDate",PXFieldTypeDate::build,
  606.     __DELTA(PXFieldTypeDate));
  607.  
  608. // Description -------------------------------------------------------------
  609. //
  610. //    When the streamable constructor is called, TStreamable dispatches
  611. //    the build member to construct the object.  To do this, it must
  612. //    know where to find this member functions for the specific class.
  613. //    This is the reason for the stream registration.
  614. //
  615. // End ---------------------------------------------------------------------
  616.  
  617. // member read of PXFieldTypeDate //
  618.  
  619. inline Pvoid PXFieldTypeDate::read(Ripstream)
  620. {
  621.     return this;
  622. }
  623.  
  624. // member write of PXFieldTypeDate //
  625.  
  626. inline void PXFieldTypeDate::write(Ropstream)
  627. {
  628.  
  629. }
  630.  
  631. // member Get of PXFieldTypeDate //
  632.  
  633. inline int PXFieldTypeDate::Get(void)
  634. {
  635.     if((EngDataPtr->Errors.pxerr = PXGetDate(*recHandle,fld,
  636.         &data->date)) != PXSUCCESS)
  637.     {
  638.         PXError(ENG_ERROR);
  639.         return EngDataPtr->Errors.pxerr;
  640.     }
  641.     if((EngDataPtr->Errors.pxerr = PXDateDecode(data->date,
  642.         &data->month,&data->day,
  643.         &data->year)) != PXSUCCESS)
  644.         PXError(ENG_ERROR);
  645.     else
  646.         sprintf(char_dat,"%02d-%02d-%02d",data->month,data->day,
  647.             data->year);
  648.     return EngDataPtr->Errors.pxerr;
  649. }
  650.  
  651. // Summary -----------------------------------------------------------------
  652. //
  653. //     Get the DATES data, decodes it and convert it to character data.
  654. //
  655. // Return Value
  656. //
  657. //    pxerr.  Return PDOX error code.
  658. //
  659. // End ---------------------------------------------------------------------
  660.  
  661. // member Put of PXFieldTypeDate //
  662.  
  663. inline int PXFieldTypeDate::Put(void)
  664. {
  665.     if((EngDataPtr->Errors.pxerr = PXDateEncode(data->month,
  666.         data->day,data->year,
  667.         &data->date)) != PXSUCCESS)
  668.     {
  669.         PXError(ENG_ERROR);
  670.         return EngDataPtr->Errors.pxerr;
  671.     }
  672.     if((EngDataPtr->Errors.pxerr = PXPutDate(*recHandle,fld,data->date))
  673.         != PXSUCCESS)
  674.         PXError(ENG_ERROR);
  675.     return EngDataPtr->Errors.pxerr;
  676. }
  677.  
  678. // Summary -----------------------------------------------------------------
  679. //
  680. //    Put the data from the data buffer into the record buffer.
  681. //
  682. // End ---------------------------------------------------------------------
  683.  
  684. // constructor PXField //
  685.  
  686. PXField::PXField(PPXRec my_object,FIELDHANDLE fldHandle)
  687. {
  688.     // Point to the engine object data
  689.  
  690.     EngDataPtr = my_object->EngDataPtr;
  691.  
  692.     // Copy record and field handles
  693.  
  694.     recHandle = my_object->recHandle;
  695.     fld = fldHandle;
  696.  
  697.     // Make the space you need to store the field type and
  698.     // name.
  699.  
  700.     fldtype = new char[MAX_FLD_TYPE_SIZE];
  701.     fldname = new char[MAX_FLD_NAME_SIZE];
  702.  
  703.     // Get the name and type of the field
  704.  
  705.     if((EngDataPtr->Errors.pxerr = PXFldName(EngDataPtr->tblHandle,fld,
  706.         MAX_FLD_NAME_SIZE,fldname)) != PXSUCCESS)
  707.     {
  708.         PXError(ENG_ERROR);
  709.         return;
  710.     }
  711.     if((EngDataPtr->Errors.pxerr = PXFldType(EngDataPtr->tblHandle,fld,
  712.         MAX_FLD_TYPE_SIZE,fldtype)) != PXSUCCESS)
  713.     {
  714.         PXError(ENG_ERROR);
  715.         return;
  716.     }
  717.  
  718.     // Caste to the right field type and make that object
  719.  
  720.     switch(*fldtype)
  721.     {
  722.         case 'A':
  723.         {
  724.             my_type = new PXFieldTypeChar(this,atoi(fldtype + 1));
  725.             break;
  726.         }
  727.         case 'D':my_type = new PXFieldTypeDate(this);break;
  728.         case 'S':my_type = new PXFieldTypeShort(this);break;
  729.         case '$':my_type = new PXFieldTypeDouble(this);break;
  730.         case 'N':my_type = new PXFieldTypeDouble(this);break;
  731.     }
  732. }
  733.  
  734. // Summary -----------------------------------------------------------------
  735. //
  736. //    This constructor sets up each field of the database
  737. //
  738. // Parameters
  739. //
  740. //      tblHandle.  This is the handle for the open table.
  741. //
  742. //      recHandle.  This is the record handle for the current record.
  743. //
  744. // Functional Description
  745. //
  746. //    1.  Copy all the parameters.
  747. //
  748. //    2.  Make some space to save the field name and type.
  749. //
  750. //    3.  Get the name and type of the field.
  751. //
  752. //    4.  Call the constructor for the given type.
  753. //
  754. // End ---------------------------------------------------------------------
  755.  
  756. // constructor PXField //
  757.  
  758. PXField::PXField(PPXField my_field)
  759. {
  760.     EngDataPtr = my_field->EngDataPtr;
  761.     fld = my_field->fld;
  762.     recHandle = my_field->recHandle;
  763.     fldtype = NULL;
  764.     fldname = NULL;
  765.     my_type = NULL;
  766. }
  767.  
  768. // Summary -----------------------------------------------------------------
  769. //
  770. //    Copies info to initialize engine object.  It's very important that
  771. //    you NULL your pointers out so that the destructor does not delete
  772. //    something that was never allocated!!
  773. //
  774. // End ---------------------------------------------------------------------
  775.  
  776. PXField::~PXField(void)
  777. {
  778.     delete fldtype;
  779.     fldtype = NULL;
  780.     delete fldname;
  781.     fldname = NULL;
  782.     delete my_type;
  783.     my_type = NULL;
  784. }
  785.  
  786. // member build of PXField //
  787.  
  788. PTStreamable PXField::build()
  789. {
  790.     return new PXField(streamableInit);
  791. }
  792.  
  793. TStreamableClass RegPXField("PXField",PXField::build,
  794.     __DELTA(PXField));
  795.  
  796. // Description -------------------------------------------------------------
  797. //
  798. //    When the streamable constructor is called, TStreamable dispatches
  799. //    the build member to construct the object.  To do this, it must
  800. //    know where to find this member functions for the specific class.
  801. //    This is the reason for the stream registration.
  802. //
  803. // End ---------------------------------------------------------------------
  804.  
  805. // member read of PXField //
  806.  
  807. inline Pvoid PXField::read(Ripstream)
  808. {
  809.     return this;
  810. }
  811.  
  812. // member write of PXField //
  813.  
  814. inline void PXField::write(Ropstream)
  815. {
  816.  
  817. }
  818.  
  819. // member Get of PXField //
  820.  
  821. inline char *PXField::Get()            /* Get the field data */
  822. {
  823.     if(my_type->Get())
  824.         return NULL;
  825.     return my_type->RetCharData();
  826. }
  827.  
  828. // Summary -----------------------------------------------------------------
  829. //
  830. //    Gets data of the field type. and returns it.
  831. //
  832. // Return Value
  833. //
  834. //    returns character version of field data for any type.
  835. //
  836. // End ---------------------------------------------------------------------
  837.  
  838. // member RetCharSize of PXField //
  839.  
  840. inline int PXField::RetCharSize()
  841. {
  842.     return my_type->RetCharSize();
  843. }
  844.  
  845. // Summary -----------------------------------------------------------------
  846. //
  847. //    Returns the number of characters it takes to display this field.
  848. //
  849. // Return Value
  850. //
  851. //    Returns the number of characters for this field type.
  852. //
  853. // End ---------------------------------------------------------------------
  854.  
  855. // member PXError of PXField //
  856.  
  857. inline void PXField::PXError(int org)
  858. {
  859.     // Calls base class error handler.
  860.  
  861.     PXEngObject::PXError(org);
  862.  
  863.     // Call the parents error handler
  864.  
  865.     EngDataPtr->PXEObjPtr->EngDataPtr->Errors.pxerr =
  866.         EngDataPtr->Errors.pxerr;
  867.     EngDataPtr->PXEObjPtr->PXError(EngDataPtr->Errors.Origin);
  868. }
  869.  
  870. // Summary -----------------------------------------------------------------
  871. //
  872. //    If you have an error, the parent error handler is called.
  873. //
  874. // End ---------------------------------------------------------------------
  875.  
  876. #endif // PXFIELD_CPP //
  877.